﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using CMS.BLL;

public partial class Controls_Galleries_ctrGalleryList_Homepage : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.InitData();
            this.BindData();
        
        }
    }
    private void InitData()
    {
        int nCurrentLanguage = Support.GetCurrentLanguage();

        lblGallery.Text = MultipleLanguage.GALLERY[nCurrentLanguage -1];
        lnkShowall.Text = MultipleLanguage.SHOWALL[nCurrentLanguage - 1];
        lnkShowall.NavigateUrl = "~/Gallery.aspx";
    }

    private void BindData()
    {
        int nPageCount = 0;
        Albums objAlbum = new Albums();
        DataTable dtbAlbum = new DataTable();
        dtbAlbum = objAlbum.Search(1, "", 1, 1, ref nPageCount);
        rptGal.DataSource = dtbAlbum;
        rptGal.DataBind();

        //int nCount = dtbAlbum.Rows.Count;

        //if (nCount > 0)
        //{
        //    int nLastestAlbum = ConvertData.ConvertToInt(dtbAlbum.Rows[0]["AlbumID"]);

        //    AlbumImages objAlbumImage = new AlbumImages();
        //    DataTable dtbAlbumImage = new DataTable();
        //    dtbAlbumImage = objAlbumImage.Search(nLastestAlbum, 1, 1000, ref nPageCount);
        //    rptGal.DataSource = dtbAlbumImage;
        //    rptGal.DataBind();
        //}
     
        
    }


    protected void rptGal_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if ((e.Item.ItemType != ListItemType.Header) && (e.Item.ItemType != ListItemType.Footer))
        {

            Image imgGal = (Image)e.Item.FindControl("imgGal");
            int nID = ConvertData.ConvertToInt(DataBinder.Eval(e.Item.DataItem, "AlbumID"));
            imgGal.ImageUrl = "~/Images/Upload/Gallery/" + ConvertData.ConvertToString(DataBinder.Eval(e.Item.DataItem, "AlbumImage"));
        }
    }
}
